package com.power.sifa.approve.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import com.power.sifa.approve.model.Apl_arrive_receipt;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.List;

/**
 * 送达回执 持久层(hibernate)
 */

public interface Apl_arrive_receiptDao extends JpaRepository<Apl_arrive_receipt, Serializable>, JpaSpecificationExecutor<Apl_arrive_receipt>, Repository<Apl_arrive_receipt, Serializable>, Apl_arrive_receiptDaoCustom<Apl_arrive_receipt, Serializable> {

   @Modifying
   @Transactional
   @Query("delete  from Apl_arrive_receipt s where  s.id in (:ids) ")
   void removeByIds(@Param("ids") List<Integer> ids);

   /**
    * 更新送达回执状态
    * @param id
    * @param status
    */
   @Modifying
   @Transactional
   @Query("update Apl_arrive_receipt s set s.status = :status where  s.id = :id ")
   void updatesStatus(String id, Integer status);

   @Query(" from Apl_arrive_receipt s where s.code = :code and s.verifycode = :verifycode ")
   Apl_arrive_receipt getByCode(String code, String verifycode);

   @Query(" from Apl_arrive_receipt s where s.verifycode = :verifycode ")
   Apl_arrive_receipt getByVerifycode(String verifycode);
}
